﻿//Chargement de la page
$(function () {

    //Gestion du css pour les menus
    var uriCourant = document.location.pathname;
    var indiceDepart = uriCourant.lastIndexOf('/') + 1; // Plus 1 car on ne veut pas le '/'. 
    var indiceArrivee = uriCourant.length - 5; // Moins les 5 caractères de l'extension. 
    var nompage = uriCourant.substring(indiceDepart, indiceArrivee);
    //Ajout de la classe current à l'élément du menu correspondant a la page 
    $("#" + nompage).addClass("current").removeClass("select");

    $(".rslides").responsiveSlides({
        auto: true,
        pager: true,
        nav: false,
        speed: 500,
        maxwidth: 800,
        namespace: "centered-btns"
    });

    $("#onglet div").hide(); // Initially hide all content
    $("#tabs li:first").attr("id", "current"); // Activate first tab
    $("#onglet div:first").fadeIn(); // Show first tab content
    $("#onglet div:first div").fadeIn(); // Show first tab content

    $('#tabs a').live("click", function (e) {
        e.preventDefault();
        if ($(this).closest("li").attr("id") == "current") { //detection for current tab
            return
        }
        else {
            $("#onglet div.typeProduit ").hide(); //Hide all content
            $("#tabs li").attr("id", ""); //Reset id's
            $(this).parent().attr("id", "current"); // Activate this
            $('#' + $(this).attr('name')).fadeIn(); // Show content for current tab
            $('#' + $(this).attr('name')).find("div").fadeIn();
        }
        return false;
    });

    //Caption Sliding (Partially Hidden to Visible)
    $('.boxgrid.caption').live('mouseover mouseout', function (event) {
        if (event.type == 'mouseover') {
            $(".cover", this).stop().animate({ top: '160px' }, { queue: false, duration: 160 });
        } else {
            $(".cover", this).stop().animate({ top: '220px' }, { queue: false, duration: 160 });
        }
    });

});